package options;

import gui.OptionsTest;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 * Optionsfenster der Aufgaben
 * 
 * @author Michi
 * 
 */
public class ToDoOptionPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4908353467016637277L;
	private String[] windowColorsSeperated;
	private JRadioButton rdbtnNachDatum;
	private JRadioButton rdbtnNachName;
	private JRadioButton rdbtnDatumName;
	private JRadioButton rdbtnNamedatum;

	/**
	 * Create the panel.
	 */

	// Sprache
	int speak = 0;
	String[] sortierung = { "Sortierung", "Sorting", "Voluptua" };
	String[] nachDatum = { "nach Datum", "By Date", "Per Date" };
	String[] nachName = { "nach Name", "By Name", "Per Nomen" };
	String[] darstellung = { "Darstellung", "Representation",
			"Repraesentationem" };
	String[] datumName = { "Datum - Name", "Date - Name", "Date - Nomen" };
	String[] nameDatum = { "Name - Datum", "Name - Date", "Nomen - Date" };

	/**
	 * Konstruktor
	 * 
	 * @param optionsTestInstance
	 *            Instanz des Optionsfensters
	 */
	public ToDoOptionPanel(final OptionsTest optionsTestInstance) {

		String windowColors = optionsTestInstance.getOr().getColorSetting();
		windowColorsSeperated = windowColors.split(",");
		setBackground(new Color(Integer.parseInt(windowColorsSeperated[0]),
				Integer.parseInt(windowColorsSeperated[1]),
				Integer.parseInt(windowColorsSeperated[2])));

		speak = Integer.parseInt(optionsTestInstance.getOr().getLanguage());

		setMinimumSize(new Dimension(600, 700));
		setMaximumSize(new Dimension(600, 700));
		setPreferredSize(new Dimension(600, 700));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 };
		gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0 };
		gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
		setLayout(gridBagLayout);

		JLabel lblOption = new JLabel(sortierung[speak]);
		lblOption.setFont(new Font("Lucida Grande", Font.BOLD, 13));
		GridBagConstraints gbc_lblOption = new GridBagConstraints();
		gbc_lblOption.anchor = GridBagConstraints.WEST;
		gbc_lblOption.insets = new Insets(0, 0, 5, 5);
		gbc_lblOption.gridx = 0;
		gbc_lblOption.gridy = 1;
		add(lblOption, gbc_lblOption);

		JLabel dummyLabel0 = new JLabel("   ");
		dummyLabel0.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_dummyLabel0 = new GridBagConstraints();
		gbc_dummyLabel0.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel0.gridx = 0;
		gbc_dummyLabel0.gridy = 2;
		add(dummyLabel0, gbc_dummyLabel0);

		rdbtnNachDatum = new JRadioButton(nachDatum[speak]);
		rdbtnNachDatum.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rdbtnNachDatum.setSelected(true);
				rdbtnNachName.setSelected(false);
				optionsTestInstance.setToDoOpt1("0");
			}
		});
		GridBagConstraints gbc_rdbtnNachDatum = new GridBagConstraints();
		gbc_rdbtnNachDatum.anchor = GridBagConstraints.WEST;
		gbc_rdbtnNachDatum.insets = new Insets(0, 0, 5, 5);
		gbc_rdbtnNachDatum.gridx = 2;
		gbc_rdbtnNachDatum.gridy = 3;
		add(rdbtnNachDatum, gbc_rdbtnNachDatum);

		rdbtnNachName = new JRadioButton("nach erledigt");
		rdbtnNachName.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rdbtnNachDatum.setSelected(false);
				rdbtnNachName.setSelected(true);
				optionsTestInstance.setToDoOpt1("1");
			}
		});
		GridBagConstraints gbc_rdbtnNachName = new GridBagConstraints();
		gbc_rdbtnNachName.anchor = GridBagConstraints.WEST;
		gbc_rdbtnNachName.insets = new Insets(0, 0, 5, 0);
		gbc_rdbtnNachName.gridx = 4;
		gbc_rdbtnNachName.gridy = 3;
		add(rdbtnNachName, gbc_rdbtnNachName);

		JLabel lblDummylabel = new JLabel("   ");
		lblDummylabel.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_lblDummylabel = new GridBagConstraints();
		gbc_lblDummylabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblDummylabel.gridx = 0;
		gbc_lblDummylabel.gridy = 4;
		add(lblDummylabel, gbc_lblDummylabel);

		JLabel lblOption_1 = new JLabel(darstellung[speak]);
		lblOption_1.setFont(new Font("Lucida Grande", Font.BOLD, 13));
		GridBagConstraints gbc_lblOption_1 = new GridBagConstraints();
		gbc_lblOption_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblOption_1.gridx = 0;
		gbc_lblOption_1.gridy = 5;
		add(lblOption_1, gbc_lblOption_1);

		JLabel dummyLabel1 = new JLabel("   ");
		dummyLabel1.setPreferredSize(new Dimension(12, 25));
		GridBagConstraints gbc_dummyLabel1 = new GridBagConstraints();
		gbc_dummyLabel1.insets = new Insets(0, 0, 5, 5);
		gbc_dummyLabel1.gridx = 0;
		gbc_dummyLabel1.gridy = 6;
		add(dummyLabel1, gbc_dummyLabel1);

		rdbtnDatumName = new JRadioButton(datumName[speak]);
		rdbtnDatumName.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rdbtnDatumName.setSelected(true);
				rdbtnNamedatum.setSelected(false);
				optionsTestInstance.setToDoOpt2("0");
			}
		});
		GridBagConstraints gbc_rdbtnDatumName = new GridBagConstraints();
		gbc_rdbtnDatumName.anchor = GridBagConstraints.WEST;
		gbc_rdbtnDatumName.insets = new Insets(0, 0, 5, 5);
		gbc_rdbtnDatumName.gridx = 2;
		gbc_rdbtnDatumName.gridy = 7;
		add(rdbtnDatumName, gbc_rdbtnDatumName);

		rdbtnNamedatum = new JRadioButton(nameDatum[speak]);
		rdbtnNamedatum.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rdbtnDatumName.setSelected(false);
				rdbtnNamedatum.setSelected(true);
				optionsTestInstance.setToDoOpt2("1");
			}
		});
		GridBagConstraints gbc_rdbtnNamedatum = new GridBagConstraints();
		gbc_rdbtnNamedatum.anchor = GridBagConstraints.WEST;
		gbc_rdbtnNamedatum.insets = new Insets(0, 0, 5, 0);
		gbc_rdbtnNamedatum.gridx = 4;
		gbc_rdbtnNamedatum.gridy = 7;
		add(rdbtnNamedatum, gbc_rdbtnNamedatum);

		if (optionsTestInstance.getToDoOpt1().equals("0")) {
			rdbtnNachDatum.setSelected(true);
		} else {
			rdbtnNachName.setSelected(true);
		}

		if (optionsTestInstance.getToDoOpt2().equals("0")) {
			rdbtnDatumName.setSelected(true);

		} else {
			rdbtnNamedatum.setSelected(true);
		}

	}

}
